package com.dina.saas.peccancy.domain;

import net.sf.json.JSONObject;

public class RequestPeccMsg {
	private String cmd;
	private Params params;

	public static RequestPeccMsg formJson(JSONObject jsonObj) {
		Params params = new Params();
		RequestPeccMsg r = new RequestPeccMsg();
		if (jsonObj.containsKey("cmd")) {
			r.setCmd(jsonObj.getString("cmd"));
		}
		JSONObject requestParams = (JSONObject) jsonObj.get("params");
		if (requestParams.containsKey("brandId")) {
			params.setBrandId(requestParams.getString("brandId"));
		}
		if (requestParams.containsKey("engineNo")) {
			params.setEngineNo(requestParams.getString("engineNo"));
		}
		if (requestParams.containsKey("vehicleType")) {
			params.setVehicleType(requestParams.getString("vehicleType"));
		}
		if (requestParams.containsKey("provice")) {
			params.setProvice(requestParams.getString("provice"));
		}
		if (requestParams.containsKey("startDate")) {
			params.setStartDate(requestParams.getString("startDate"));
		}
		if (requestParams.containsKey("endDate")) {
			params.setEndDate(requestParams.getString("endDate"));
		}
		if (requestParams.containsKey("pageSize")) {
			params.setPagesize(requestParams.getInt("pageSize"));
		}
		if (requestParams.containsKey("pageNo")) {
			params.setPageNo(requestParams.getInt("pageNo"));
		}
		r.setParams(params);
		return r;

	}

	public String getCmd() {
		return cmd;
	}

	public void setCmd(String cmd) {
		this.cmd = cmd;
	}

	public Params getParams() {
		return params;
	}

	public void setParams(Params params) {
		this.params = params;
	}

}
